#pragma once
// MESSAGE SENSER_ALT PACKING

#define MAVLINK_MSG_ID_SENSER_ALT 160

MAVPACKED(
typedef struct __mavlink_senser_alt_t {
 float alt; /*< [m] normal altitude*/
 float alt_bar; /*< [cm] Barometric altitude*/
 float alt_csb; /*< [cm] Ultrasonic altitude*/
}) mavlink_senser_alt_t;

#define MAVLINK_MSG_ID_SENSER_ALT_LEN 12
#define MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN 12
#define MAVLINK_MSG_ID_160_LEN 12
#define MAVLINK_MSG_ID_160_MIN_LEN 12

#define MAVLINK_MSG_ID_SENSER_ALT_CRC 228
#define MAVLINK_MSG_ID_160_CRC 228



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_SENSER_ALT { \
    160, \
    "SENSER_ALT", \
    3, \
    {  { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_senser_alt_t, alt) }, \
         { "alt_bar", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_senser_alt_t, alt_bar) }, \
         { "alt_csb", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_senser_alt_t, alt_csb) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_SENSER_ALT { \
    "SENSER_ALT", \
    3, \
    {  { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_senser_alt_t, alt) }, \
         { "alt_bar", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_senser_alt_t, alt_bar) }, \
         { "alt_csb", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_senser_alt_t, alt_csb) }, \
         } \
}
#endif

/**
 * @brief Pack a senser_alt message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param alt [m] normal altitude
 * @param alt_bar [cm] Barometric altitude
 * @param alt_csb [cm] Ultrasonic altitude
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_senser_alt_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               float alt, float alt_bar, float alt_csb)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SENSER_ALT_LEN];
    _mav_put_float(buf, 0, alt);
    _mav_put_float(buf, 4, alt_bar);
    _mav_put_float(buf, 8, alt_csb);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENSER_ALT_LEN);
#else
    mavlink_senser_alt_t packet;
    packet.alt = alt;
    packet.alt_bar = alt_bar;
    packet.alt_csb = alt_csb;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENSER_ALT_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_SENSER_ALT;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
}

/**
 * @brief Pack a senser_alt message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param alt [m] normal altitude
 * @param alt_bar [cm] Barometric altitude
 * @param alt_csb [cm] Ultrasonic altitude
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_senser_alt_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   float alt,float alt_bar,float alt_csb)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SENSER_ALT_LEN];
    _mav_put_float(buf, 0, alt);
    _mav_put_float(buf, 4, alt_bar);
    _mav_put_float(buf, 8, alt_csb);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SENSER_ALT_LEN);
#else
    mavlink_senser_alt_t packet;
    packet.alt = alt;
    packet.alt_bar = alt_bar;
    packet.alt_csb = alt_csb;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SENSER_ALT_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_SENSER_ALT;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
}

/**
 * @brief Encode a senser_alt struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param senser_alt C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_senser_alt_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_senser_alt_t* senser_alt)
{
    return mavlink_msg_senser_alt_pack(system_id, component_id, msg, senser_alt->alt, senser_alt->alt_bar, senser_alt->alt_csb);
}

/**
 * @brief Encode a senser_alt struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param senser_alt C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_senser_alt_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_senser_alt_t* senser_alt)
{
    return mavlink_msg_senser_alt_pack_chan(system_id, component_id, chan, msg, senser_alt->alt, senser_alt->alt_bar, senser_alt->alt_csb);
}

/**
 * @brief Send a senser_alt message
 * @param chan MAVLink channel to send the message
 *
 * @param alt [m] normal altitude
 * @param alt_bar [cm] Barometric altitude
 * @param alt_csb [cm] Ultrasonic altitude
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_senser_alt_send(mavlink_channel_t chan, float alt, float alt_bar, float alt_csb)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_SENSER_ALT_LEN];
    _mav_put_float(buf, 0, alt);
    _mav_put_float(buf, 4, alt_bar);
    _mav_put_float(buf, 8, alt_csb);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSER_ALT, buf, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
#else
    mavlink_senser_alt_t packet;
    packet.alt = alt;
    packet.alt_bar = alt_bar;
    packet.alt_csb = alt_csb;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSER_ALT, (const char *)&packet, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
#endif
}

/**
 * @brief Send a senser_alt message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_senser_alt_send_struct(mavlink_channel_t chan, const mavlink_senser_alt_t* senser_alt)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_senser_alt_send(chan, senser_alt->alt, senser_alt->alt_bar, senser_alt->alt_csb);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSER_ALT, (const char *)senser_alt, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
#endif
}

#if MAVLINK_MSG_ID_SENSER_ALT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_senser_alt_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  float alt, float alt_bar, float alt_csb)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_float(buf, 0, alt);
    _mav_put_float(buf, 4, alt_bar);
    _mav_put_float(buf, 8, alt_csb);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSER_ALT, buf, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
#else
    mavlink_senser_alt_t *packet = (mavlink_senser_alt_t *)msgbuf;
    packet->alt = alt;
    packet->alt_bar = alt_bar;
    packet->alt_csb = alt_csb;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SENSER_ALT, (const char *)packet, MAVLINK_MSG_ID_SENSER_ALT_MIN_LEN, MAVLINK_MSG_ID_SENSER_ALT_LEN, MAVLINK_MSG_ID_SENSER_ALT_CRC);
#endif
}
#endif

#endif

// MESSAGE SENSER_ALT UNPACKING


/**
 * @brief Get field alt from senser_alt message
 *
 * @return [m] normal altitude
 */
static inline float mavlink_msg_senser_alt_get_alt(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  0);
}

/**
 * @brief Get field alt_bar from senser_alt message
 *
 * @return [cm] Barometric altitude
 */
static inline float mavlink_msg_senser_alt_get_alt_bar(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  4);
}

/**
 * @brief Get field alt_csb from senser_alt message
 *
 * @return [cm] Ultrasonic altitude
 */
static inline float mavlink_msg_senser_alt_get_alt_csb(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  8);
}

/**
 * @brief Decode a senser_alt message into a struct
 *
 * @param msg The message to decode
 * @param senser_alt C-struct to decode the message contents into
 */
static inline void mavlink_msg_senser_alt_decode(const mavlink_message_t* msg, mavlink_senser_alt_t* senser_alt)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    senser_alt->alt = mavlink_msg_senser_alt_get_alt(msg);
    senser_alt->alt_bar = mavlink_msg_senser_alt_get_alt_bar(msg);
    senser_alt->alt_csb = mavlink_msg_senser_alt_get_alt_csb(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_SENSER_ALT_LEN? msg->len : MAVLINK_MSG_ID_SENSER_ALT_LEN;
        memset(senser_alt, 0, MAVLINK_MSG_ID_SENSER_ALT_LEN);
    memcpy(senser_alt, _MAV_PAYLOAD(msg), len);
#endif
}
